package repository

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/commRedis"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/Json"
	"time"
)

type repoCloudCacheService struct {
}

func (e *repoCloudCacheService) init() {
}

func (e *repoCloudCacheService) SaveList(modelType string, list []map[string]interface{}) {
	jsn := Json.BuildJson(list)
	commRedis.Client.Set("fox-edge:list:manage:repo:cache:"+modelType, jsn, 0*time.Millisecond).Result()
}

func (e *repoCloudCacheService) ReadList(modelType string) []map[string]interface{} {
	jsn, err := commRedis.Client.Get("fox-edge:list:manage:repo:cache:" + modelType).Result()
	if err != nil {
		return make([]map[string]interface{}, 0)
	}

	return Json.BuildMapListByJson(jsn)
}
